﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RedfieldWeather.Controls
{
	public partial class Temperature : System.Web.UI.UserControl
	{
		public void SetCurrentConditions(RFW.Weather.CurrentConditions cc)
		{
			lblTemp.Text = string.Format("{0:N1}&deg; F<br />Feels like {1:N1}&deg; F", cc.Temperature.Degrees, cc.Temperature.Degrees <= 45 ? cc.Temperature.WindChill : cc.Temperature.HeatIndex);
			lblTempHigh.Text = string.Format("{0:N1}&deg; F at {1:t}", cc.Temperature.High.Value, cc.Temperature.High.Time);
			lblTempLow.Text = string.Format("{0:N1}&deg; F at {1:t}", cc.Temperature.Low.Value, cc.Temperature.Low.Time);
			lblComfortLevel.Text = cc.Forecast.ComformatLevel;
			lblHumidity.Text = string.Format("{0:N0}%", cc.Humidity.Percentage);

			if (cc.Temperature.Rate > 0)
				lblChange.Text = "&uarr;";
			else if (cc.Temperature.Rate == 0)
				lblChange.Text = "&nbsp;";
			else
				lblChange.Text = "&darr;";

			if (cc.Humidity.Rate > 0)
				lblHumidityChange.Text = "&uarr;";
			else if (cc.Humidity.Rate == 0)
				lblHumidityChange.Text = "&nbsp;";
			else
				lblHumidityChange.Text = "&darr;";
		}
	}
}